package locations.actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import locations.dao.DAOFactory;
import locations.dao.InstitutionResponsibleDAO;
import locations.model.InstitutionResponsible;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class SaveInstitutionResponsibleAction extends ActionSupport implements ModelDriven<InstitutionResponsible>, ServletRequestAware, ServletResponseAware {

private static final long serialVersionUID = -8124967730231198191L;
	
	private HttpServletRequest request; 
	private HttpServletResponse response; 
	private InstitutionResponsible institutionResponsible = new InstitutionResponsible();
	
	public String execute(){
		InstitutionResponsibleDAO dao = DAOFactory.getInstitutionResponsibleDAO();
		dao.save(this.institutionResponsible);
		return SUCCESS;
	}
	
	public HttpServletRequest getRequest() {
		return request;
	}

	
	public InstitutionResponsible getInstitutionResponsible() {
		return institutionResponsible;
	}



	public void setInstitutionResponsible(
			InstitutionResponsible institutionResponsible) {
		this.institutionResponsible = institutionResponsible;
	}



	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}



	public void setResponse(HttpServletResponse response) {
		this.response = response;
	}



	public HttpServletResponse getResponse(){
		return this.response;
	}
	
	@Override
	public void setServletResponse(HttpServletResponse response) {
	
		this.response = response;
	}

	@Override
	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
		
	}

	@Override
	public InstitutionResponsible getModel() {

		return this.institutionResponsible;
	}

}
